/** @jsxImportSource @emotion/react */
import * as React from "react";
import {CCell, Cell, Table, TableBody, TableRow, Text,} from "customize-easy-ui-component";
import {usePrefixDataTable} from "../../hook/usePrefixData";
import {TailMenRowIspCheck} from "../../contain/rarelyVary";
import {configSetter} from "./Regular.O-1";
import {RepLink} from "../../common/base";

export const 资料审查报告= ({theme, orc, rep} :{theme: any, orc:any, rep:any}
) => {
  const [config资料审查上,config资料审查下] = React.useMemo(() => {
    const allCfg=configSetter(rep?.modelversion,orc);
    //拆分成2个, 两表的预期中的列数差了1列！
    return[allCfg.slice(0, 10),  allCfg.slice(10)];
  }, [rep?.modelversion,orc]);
  // const [renderUpper,_S]=useThreeColumnView({orc, config:newconfig概况,slash:true,});
  const renderUpper=usePrefixDataTable({config: config资料审查上, orc, rep, slash:true});
  const renderMiddle=usePrefixDataTable({config: config资料审查下, orc, rep, slash:true,
      embed: { 0:  <CCell split rowSpan={12}>性能参数</CCell>,  },
  });
  return <>
    <div css={{"@media print": {paddingBottom: '4rem', pageBreakInside: 'avoid'}} }>
      <Text id='MaterialReview' variant="h2" css={{
        textAlign: 'center', marginTop: '1rem',
      }}>压力容器资料审查报告</Text>
      <div css={{
        display: 'flex',
        justifyContent: 'space-between'
      }}>
        <Text>单位内部编号：{orc.单位内部编号}</Text>
        <Text>报告编号：{rep.isp.no}</Text>
      </div>
    </div>
    <Table  fixed={ ["4.2%","12.1%","39%","9%","11.1%","%"] }  tight  miniw={800}
            css={ {borderCollapse: 'collapse', "@media print": {marginTop: '-4rem'}} } >
      <TableBody>
        <RepLink rep={rep} tag={'MaterialReview'}>
          {renderUpper}
        </RepLink>
      </TableBody>
    </Table>
    <Table  fixed={ ["4.2%","4%","8.2%","38.8%","4%","16.3%","%"] } css={ {borderCollapse: 'collapse', } }  tight  miniw={800}>
      <TableBody>
        <RepLink rep={rep} tag={'MaterialReview'}>
          {renderMiddle}
        </RepLink>
      </TableBody>
    </Table>
    <Table  fixed={ ["8.1%",  "%"] } css={ {borderCollapse: 'collapse' } } tight  miniw={800}>
      <TableBody>
        <RepLink rep={rep} tag={'PreviousQuestion'}>
          <TableRow>
            <CCell>资料审查情况</CCell>
            <Cell split={true} colSpan={4}><div css={{minHeight: '3rem', whiteSpace: 'pre-wrap'}}>
              {orc.资料审查 || '／'}
            </div></Cell>
          </TableRow>
          <TableRow>
            <CCell>上次定期检验问题记载</CCell>
            <Cell split={true} colSpan={4}><div css={{minHeight: '3rem', whiteSpace: 'pre-wrap'}}>
              上次定期检验安全状况等级评为&nbsp; {orc.上次评级}<br/>
              {orc.上次缺处 || '／'}
            </div></Cell>
         </TableRow>
        </RepLink>
      </TableBody>
    </Table>
    <TailMenRowIspCheck orc={orc} rep={rep} />
  </>;
};
